<template>
	<view class="container">
		<view v-if="state == true">
			<!-- 巡检端 -->
			<onSiteMine ref='mine' @getinfo='getinfo'></onSiteMine>
		</view>
		<view v-else>
			<!-- 工长端 -->
			<foremanMine ref='foremanMIne' @getinfo='getinfo'></foremanMine>
		</view>
	</view>
</template>
<script>
	import onSiteMine from '@/pages/onSite/mine.vue'
	import foremanMine from '@/pages/foreman/foremanMIne.vue'
	import {
		mapMutations,
		mapActions,
		mapState,
		mapGetters
	} from 'vuex';
	export default {
		data() {
			return {
				infoState: '',
				state: true,
			}
		},
		computed: {
			...mapGetters(['userInfo'])
		},
		components: {
			foremanMine,
			onSiteMine
		},
		onShow() {
			if (this.userInfo.roleType == '3' || uni.getStorageSync('userInfo').roleType == '3') {
				uni.setNavigationBarTitle({
					title: '家装顾问-巡检'
				});
				this.state = true
			} else if (this.userInfo.roleType == '2' || uni.getStorageSync('userInfo').roleType == '2') {
				uni.setNavigationBarTitle({
					title: '家装顾问-工长'
				});
				this.state = false
			}

		},
		methods: {
			onPullDownRefresh() {
				console.log('refresh');
				if (this.userInfo.roleType == '3' || uni.getStorageSync('userInfo').roleType == '3') {
					this.$refs.mine.getinfo()
				} else if (this.userInfo.roleType == '2' || uni.getStorageSync('userInfo').roleType == '2') {
					this.$refs.foremanMIne.getinfo()
				}
				setTimeout(function() {
					uni.stopPullDownRefresh();
				}, 1000);
			},
		}
	}
</script>

<style scoped>
.container{
	/* width: 100vh; */
	height:100vh;
}
</style>
